@extends('admin.home.main')

@section('body')
<section id="main-content">
	  <section class="wrapper">
		<h3>课程分类编辑</h3>
		<!-- BASIC FORM ELELEMNTS -->
		<div class="row mt">
		  <div class="col-lg-12">
			<div class="form-panel">
			  <form class="form-horizontal style-form" action="/admin/coursetype/update" method="post">
			  	<input type="hidden" id="_token" name="_token" value="{{csrf_token()}}">
			  	<input type="hidden" name="id" id="id" value="{{$contentinfo->id}}">
			  	<input type="hidden" name="courseid" id="courseid" value="{{$contentinfo->curriculum_id}}">
				  <input type="hidden" name="video_link" id="video_link" value="{{$contentinfo->video_link}}">
				<div class="form-group">
				  <label class="col-sm-2 col-sm-2 control-label">视频名称</label>
				  <div class="col-sm-10">
					<input type="" class="form-control" id="video_name" value="{{$num}}" name="" style="width:400px;">
				  </div>
				</div>
				  <div class="form-group">
					  <label class="col-sm-2 col-sm-2 control-label">视频点击量</label>
					  <div class="col-sm-10">
						  <input type="" class="form-control" id="hit" value="{{$contentinfo->hits}}" name=""
								 style="width:400px;">
					  </div>
				  </div>
				  <div class="form-group">
					  <label class="col-sm-2 col-sm-2 control-label">视频时长</label>
					  <div class="col-sm-10">
						  <input type="" class="form-control" id="video_length" value="{{$contentinfo->video_length}}"
								 name=""
								 style="width:100px; float:left;"><span style="height:35px; line-height:35px;
								 float:left; margin-left:10px;">秒</span>
					  </div>
				  </div>
				<div class="form-group">
				  <label class="col-sm-2 col-sm-2 control-label">是否免费</label>
				  <div class="col-sm-10">
					<input type="radio" name="is_free" class="is_free" value="0" @if($contentinfo->is_free == 0) checked="checked" @endif>免费
					<input type="radio" name="is_free" class="is_free" value="1" @if($contentinfo->is_free == 1) checked="checked" @endif>不免费
				  </div>
				</div>

				<div class="form-group">
				  <label class="col-sm-2 col-sm-2 control-label">是否分享</label>
				  <div class="col-sm-10">
					<input type="radio" name="is_share" class="is_share" value="1" @if($contentinfo->is_share == 1) checked="checked" @endif>可分享
					<input type="radio" name="is_share" class="is_share" value="0" @if($contentinfo->is_share == 0) checked="checked" @endif>不可分享
				  </div>
				</div>
				
				<button type="button" id="save" class="btn btn-success">提交</button>
				<button type="reset" class="btn btn-primary">重置</button>
			  </form>
			</div>
		  </div>
		  <!-- col-lg-12-->
		</div>

		
	  </section>
	  <!-- /wrapper -->
	</section>
<script type="text/javascript">
	$('#save').click(function(){
		var _token = $('#_token').val(),
			id = $('#id').val(),
			video_name = $('#video_name').val(),
			video_length=$('#video_length').val(),
			courseid = $('#courseid').val(),
			video_link = $('#video_link').val(),
			video_hits = $('#hit').val(),
			isshare = '',
			isfree = '';

		$('.is_free').each(function(){
			if($(this).is(':checked')){
				isfree = $(this).val();
			}
		})

		$('.is_share').each(function(){
			if($(this).is(':checked')){
				isshare = $(this).val();
			}
		})

		$.ajax({
			url:'/admin/course/video_modi',
			type:'post',
			data:{'_token':_token,'id':id,'courseid':courseid,'isshare':isshare,'isfree':isfree,
				'video_name':video_name,'video_hits':video_hits,'video_length':video_length,'video_link':video_link},
			dataType:'json',
			success:function(msg){
				if(msg.code == 200){
					alert('编辑成功');
					location.href="/admin/course/view_video_list/"+courseid;
				}else{
					alert('编辑失败');
					location.reload();
				}
			}
		})
	})
</script>
@endsection